<html>
  <head>
    <style>
      #results li.failure { color:red; }   
      #results li.pending { color:blue; } 
      text#behavior-test
      {
        prototype:bhvB;
      }
    </style>
  <script type="text/tiscript">
  
    var ulr = self.select("#results");
  
    function run(TestFunc)
    {
      var li = new Element("li");
      ulr.insert(li);
      try 
      {
        var r = TestFunc();
        if( typeof r == #function ) 
        { // function returns promise
          li.text = String.printf("%s running ...", TestFunc );
          li.@#class = "pending";
          r.then( function(v) { 
              li.text = String.printf("%s passed", TestFunc ); 
              li.@#class = "passed";
          });
          r.catch( function(err) { 
              li.html = String.printf("%s failed with <pre>%s</pre>", TestFunc, err );
              li.@#class = "failure";
          }); 
        }
        else 
          li.text = String.printf("%s passed", TestFunc );
      }
      catch(err)
      {
        li.html = String.printf("%s failed with <pre>%s</pre>", TestFunc, err );
        li.@#class = "failure";
        debug error: err.toString();
      }
    }
    include "tiscript-tests.tis";
    include "tiscript-behaviors-tests.tis";
    
    function self.ready()
    {
      run( Super_Behavior_test );    
    }
    
  </script>
  </head>
<body>
  <h1>TIScript basic tests</h1> 
  <ul #results>
    
  </ul>
  <text #behavior-test>behavior-test</text>
</body>
</html>